<template>
	<view>
		<!-- <u-tabs :list="list1" :current='current' lineWidth='200' :scrollable='false' @click="clicktab"></u-tabs> -->
		<view class="" v-if="current==0">
			<view class="u-p-20 m-t-20 flex-between" @click="topeopleinfo(i.community_unit_id)" v-for="i in houselist">
				<text>{{i.addr}}</text>
				<view class="role u-radius-5" @click.stop="show=true" >
					···
				</view>
			</view>
			<!-- <u-action-sheet @select='select' @close="show = false" cancelText="关闭" :actions="list"
				:show="show"></u-action-sheet> -->
		</view>
		<view class="" v-else>
			<view class="addnew" @click="toNewauthorization" >
				<view class="role u-font-28 u-radius-5" style="color: #fff; background-color: #409EFF; ">
					新增授权
				</view>
			</view>
			<view class="u-p-30 u-font-28" v-for="i in userlog">
				<view class="flex-between">
					<view class="flex-center">
						<view class="role u-radius-5 u-shrink-no u-m-r-24">
							{{i.role_name}}
						</view>
						<text class="" >{{i.user_info.nick_name}}</text>
						<text class="main-color u-m-l-12">{{i.user_info.mobile}}</text>
					</view>
					<view class="role u-radius-5 u-shrink-no " @click="show = true,user_id=i.user_info.user_id">
						删除
					</view>
				</view>
				<view class="u-m-tb-22 flex" style="align-items: center;">
					<image src="../../static/zxcimg/dy.png" class="w36 h36 u-m-r-10" mode=""></image>
					<text>{{i.address}}</text>
				</view>
				<!-- <u-checkbox-group class="flex" placement="row">
					<u-checkbox labelSize='13px' :customStyle="{marginLeft: '5px'}" v-model="i.face_status"  label="人脸识别"></u-checkbox>
					<u-checkbox labelSize='13px' :customStyle="{marginLeft: '5px'}" v-model="i.open_password_status" disabled label="开门密码"></u-checkbox>
					<u-checkbox labelSize='13px' :customStyle="{marginLeft: '5px'}" v-model="i.easy_status" disabled label="一键操作"></u-checkbox>
					<u-checkbox labelSize='13px' :customStyle="{marginLeft: '5px'}" v-model="i.user_manage_status" disabled label="用户管理"></u-checkbox>
					<u-checkbox labelSize='13px' :customStyle="{marginLeft: '5px'}" v-model="i.monitor_status" disabled label="监控"></u-checkbox>
				</u-checkbox-group> -->
				<view class="flex">
					<text v-if="i.face_status" >人脸识别</text>
					<text class="u-m-l-12" v-if="i.open_password_status" >开门密码</text>
					<text class="u-m-l-12" v-if="i.i.easy_status" >一键操作</text>
					<text class="u-m-l-12" v-if="i.user_manage_status" >用户管理</text>
					<text class="u-m-l-12" v-if="i.monitor_status" >监控</text>
				</view>
			</view>
			<u-empty v-if="current==1&&userlog.length==0" ></u-empty>
		</view>
		<u-modal :show="show" :showCancelButton='true' @cancel='show=false' @confirm='confirm' :title="title" :content='content'></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 1,
				list1: [{
					name: '单元信息',
				}, {
					name: '账号授权',
				}, ],
				list: [{
						name: '退出电梯管理 ',
					},
					{
						name: '退出房间',
					}

				],
				checkboxList1:[
					{name: '人脸识别',disabled: true},
					{name: '开门密码',disabled: true},
					{name: '一键操作',disabled: true},
					{name: '用户管理',disabled: true},
					{name: '监控',disabled: true},
				],
				checked:['人脸识别','开门密码','一键操作','用户管理'],
				show: false,
				title:'删除',
				content:'确认删除该用户吗？',
				houselist:[],
				userlog:[],
				user_id:0
			};
		},
		onLoad() {
			this.gethouse()
			this.getpower()
		},
		methods: {
			//确认删除
			confirm(){
				this.$api.post('/user_house/del',{
					form:{
						user_id:this.user_id
					}
				}).then(res=>{
					this.show = false
					this.getpower()
				})
			},
			gethouse(){
				//【首页】获取用户的单元数据
				this.$api.get('/user/door_list').then(res => {
					this.houselist = res.data
				})
			},
			//【用户管理】账号授权列表{{zhiqtech}}/api/user_house/user_log
			getpower(){
				this.$api.get('/user_house/user_log').then(res=>{
					this.userlog = res.data
				})
			},
			topeopleinfo(id){
				uni.navigateTo({
					url:'/pages/peopleinfo/peopleinfo?id=' + id
				})
			},
			clicktab(e) {
				this.current = e.index
			},
			select(e) {
				console.log(e);
			},
			toNewauthorization(){
				uni.navigateTo({
					url:'/pages/Newauthorization/Newauthorization'
				})
			},
		}
	}
</script>

<style lang="scss">
	.role {
		background-color: #E2F2FF;
		padding: 2px 8px;
		color: #409EFF;
	}

	.addnew {
		display: flex;
		justify-content: flex-end;
		margin: 30rpx 30rpx 0;
	}
</style>